package cn.tedu.weibo.controller;

import cn.tedu.weibo.common.response.JsonResult;
import cn.tedu.weibo.pojo.dto.CommentDTO;
import cn.tedu.weibo.pojo.vo.CommentVO;
import cn.tedu.weibo.pojo.vo.WeiboDetailVO;
import cn.tedu.weibo.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/comments")
public class CommentController {
    @Autowired
    ICommentService service;
    @PostMapping("add-new")
    public JsonResult addNew(@RequestBody CommentDTO commentDTO){
        service.addNew(commentDTO);
        return JsonResult.ok();
    }

    //localhost:8080/v1/comments/5/list
    @GetMapping("{weiboId}/list")
    public JsonResult list(@PathVariable Long weiboId){
        List<CommentVO> list = service.listByWeiboId(weiboId);
        return JsonResult.ok(list);
    }
}
